#include<iostream>
#include<algorithm>

using namespace std;

typedef long long LL;

const int N=2e5+10;

int h[N],s[N];
int n;


int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&h[i]);
		s[i]=s[i-1]+h[i]; 
	} 
	
	LL sum=0;
	for(int i=1;i<=n;i++) 
		sum+=(LL)h[i]*(s[n]-s[i]);
	
	printf("%lld",sum);
	
	return 0;
}
